﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.APP.Application.Command.Breeding;
using Traceability.APP.Application.Command.Health;
using Traceability.APP.Application.Command.Shop;
using Traceability.Domain;
using Traceability.ErrorCode;

namespace Traceability.APP.Controllers
{
    /// <summary>
    /// Api 控制器-保健信息
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class HealthController : ControllerBase
    {
        private readonly IMediator mediator;

        public HealthController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 保健信息的新增
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<int>> GetAdd(AddHealthCommand command)
        { 
            return mediator.Send(command);
        }

        /// <summary>
        /// 保健信息的显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<Health_Model>>> ShowAll([FromQuery] ShowAllCommand command)
        { 
            return mediator.Send(command);
        }

        /// <summary>
        /// 保健信息的修改
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<int>> UpdateHealth(UpdateHealthCommand command)
        {
            return mediator.Send(command);    
        }

        /// <summary>
        /// 保健信息的删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<int>> DelHearlth(DelHealthCommand command)
        { 
            return mediator.Send(command);
        }

    }
}
